import React from 'react'
import {connect} from 'react-redux'
import {Theme} from '@hi-ui/classic-theme'
import Category from './modules/userdata/view/Category'
import CheckIn from './modules/userdata/view/CheckIn'
import Postion from './modules/userdata/view/Postion'
import User from './modules/userdata/view/User'
import UserIdex from './modules/userdata/index'
import TestLayer from './modules/test/view/TestLayer'
import Echarts1 from './modules/test/view/Echarts1'
import testIndex from './modules/test/TestIndex'
import webIndex from './modules/WebIndex'
import Panel from './modules/panel/view/Panel'
import userDistant from './modules/test/view/UserDistant'
import {updateUserName} from "./actions/global"
import AlgorithmIndex from './modules/recommendation/index'
import UserModel from './modules/recommendation/view/usermodel/UserModel'
import UserModelDiff from './modules/recommendation/view/usermodel/UserModelDiff'
import ItemModel from './modules/recommendation/view/itemmodel/ItemModel'
import ItemModelDiff from './modules/recommendation/view/itemmodel/ItemModelDiff'
import FinalMoel from './modules/recommendation/view/finalmodel/FinalMoel'


// 路由菜单配置项
const routeConfig = [
    {path: '/index', component: webIndex},
    {name: '基本面板', path: '/base', component: Panel},
    {
        name: '算法推荐', path: '/lbsn', component: AlgorithmIndex,
        children: [
            {
                name: '用户模型',
                children: [
                    {name: '算法推荐', path: '/lbsn_userAlgorithm', component: UserModel},
                    {name: '差异分析', path: '/lbsn_userDiff', component: UserModelDiff}
                ]
            },
            {
                name: '地理模型',
                children: [
                    {name: '算法推荐', path: '/lbsn_itemAlgorithm', component: ItemModel},
                    {name: '差异分析', path: '/lbsn_itemDiff', component: ItemModelDiff}
                ]
            },
            {
                name: '混合模型',
                children: [
                    {name: 'WPR推荐', path: '/lbsn_finalAlgorithm', component: FinalMoel}
                ]
            }
        ]
    },
    {
        name: '用户数据', path: '/user', component: UserIdex,
        children: [
            {name: '用户数据', path: '/user_userinfo', component: User},
            {name: '分布地点', path: '/user_venue', component: Postion},
            {name: '签到数据', path: '/user_checkin', component: CheckIn},
            {name: '分类类型', path: '/user_category', component: Category}
        ]
    },
    {
        name: '测试单元', path: '/test', component: testIndex,
        children: [
            {name: '基本图表', path: '/test_echarts1', component: Echarts1},
            {name: 'Layer', path: '/test_layer', component: TestLayer},
            {name: '位置距离线形图', path: '/unit_distant', component: userDistant}
        ]
    }
]

// 系统 logo 配置项
const logoConfig = {
    logoUrl: 'https://xiaomi.github.io/hiui/static/img/logo.png?241e0618fe55d933c280e38954edea05', // 系统 logo
    name: 'WPR_LBSN推荐', // 系统名称
    url: 'https://gitee.com/jiajiazi/pg-lbsn-web' // 点击 logo 跳转地址
}
// 登陆信息配置项
const loginConfig = {
    name: '甲甲子',
    icon: 'user', // 登录用户 icon
    children: [
        <div key='user-info' style={{textAlign: 'center', margin: 4, width: 100}}>
            <a href='./index'>个人信息</a>
        </div>,
        <div key='logout' style={{textAlign: 'center', margin: 4, width: 100}}>
            <a href='#logout'>注销</a>
        </div>
    ] // 登录项菜单
}


const apperanceconfig = {
    color: 'light',
    contentBackground: '#f9f3fa',
    contentPadding: 10
}

class App extends React.Component {

    render() {
        const {userName} = this.props.global

        loginConfig.name = userName
        return <div><Theme
            routes={routeConfig}
            appearance={apperanceconfig}
            logo={logoConfig}
            login={loginConfig}
            type='classic'/>
            <div style={{textAlign: 'center'}}>© jiazi5279@163.com</div>
        </div>
    }
}

const mapStateToProps = state => ({
    global: state.global
})

export default connect(mapStateToProps, {
    updateUserName
})(App)
